"""
文件处理相关的工具模块
"""
def print_file_info(file_name):
    """
    将指定路径的文件内容输出到控制台
    :param file_name: 指定文件路径
    :return: None
    """
    f = None
    try:
        f = open(file_name, mode='r', encoding='utf-8')
        content = f.read()
        print("文件内容如下")
        print(content)
    except FileNotFoundError:
        print("该文件不存在！")
    finally:
        if f:
         f.close()

def append_to_file(file_name, data):
    f = None
    try:
        f = open(file_name, mode='a', encoding='utf-8')
        f.write(data)
        f.flush()
    except FileNotFoundError:
        print("文件不存在哦~")
    finally:
        f.close()

if __name__ == '__main__':
    print_file_info("D:/Project/Python-Project/test.txt")